import { Window } from "../../../component/window/Window";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { CacheManager } from "../../../../com/gengine/manager/CacheManager";
import { MsgManager } from "../../manager/MsgManager";
import { GButton } from "../../../../com/mui/controls/GButton";
//class LocalCacheSetWindow
    
    export  class LocalCacheSetWindow extends Window
    {
        constructor()
        {
            super();
            if (LocalCacheSetWindow._instance) 
            {
                throw new Error("LocalCacheSetWindow单例");
            }
            setSize(593, 403);
            return;
        }

        protected /* override */ createChildren(): void
        {
            _isAddClolseButton = false;
            _isAddHelpButton = false;
            super.createChildren();
            this._windowBg1 = new Object /* flash.display.Bitmap */();
            $addChildAt(this._windowBg1, 0);
            LoaderManager.instance.load("LocalSetBg.png", this.onLoadedHandler, 3, null, null, this.onLoadFailHandler);
            return;
        }

        /* internal  */onLoadedHandler(arg1: ImageInfo): void
        {
            this._windowBg1.bitmapData = arg1.bitmapData;
            if (this._okBtn == null) 
            {
                this._okBtn = ObjCreate.createGButton(Language.getString(51038), 270, 355, 70, 25, this.contentSprite, "DialogOptBtn");
                this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOkBtnClickHandler);
            }
            return;
        }

        /* internal  */onLoadFailHandler(arg1): void
        {
            this.hide();
            CacheManager.instance.setLocalCache();
            return;
        }

        /* internal  */onOkBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (CacheManager.instance.isCache) 
            {
                MsgManager.showRollTipsMsg(Language.getString(51039));
            }
            CacheManager.instance.setLocalCache();
            this.hide();
            return;
        }

        public static get instance(): LocalCacheSetWindow
        {
            if (LocalCacheSetWindow._instance == null) 
            {
                LocalCacheSetWindow._instance = new LocalCacheSetWindow();
            }
            return LocalCacheSetWindow._instance;
        }

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_windowBg1: Object /* flash.display.Bitmap */;

        /* internal */ static /* var */_instance: LocalCacheSetWindow;
    }
